package UDP.udpTranslate;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class UdpTranslateServer extends UdpEchoServer {
    private Map<String, String> map = new HashMap<>();
    public UdpTranslateServer(int port) throws SocketException {
        super(port);
        map.put("cat", "小猫");
        map.put("paino", "钢琴");
        map.put("dog", "狗");
    }
    public String process(String request) {
        return map.getOrDefault(request, "未能找到该词");
    }
    public static void main(String[] args) throws IOException {
        UdpTranslateServer server = new UdpTranslateServer(9090);
        server.start();
    }
}

